--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tests/frontend/NotificationBell.test.js b255dbb03e693a26b11a1be4d0563201bc276ec2 (b255dbb0) Text, 3.46 KB
Tff7b72import Tb4b4b4{ Te6edf3mount Tb4b4b4} Tff7b72from Ta5d6ff"@vue/test-utils"Tb4b4b4;
Tff7b72import Tb4b4b4{ Te6edf3describeTb4b4b4, Te6edf3itTb4b4b4, Te6edf3expectTb4b4b4, Te6edf3viTb4b4b4, Te6edf3beforeEach Tb4b4b4} Tff7b72from Ta5d6ff"vitest"Tb4b4b4;
Tff7b72import Te6edf3NotificationBell Tff7b72from Ta5d6ff"../../meshchatx/src/frontend/components/NotificationBell.vue"Tb4b4b4;
Te6edf3viTb4b4b4.Te6edf3mockTb4b4b4(Ta5d6ff"../../meshchatx/src/frontend/js/WebSocketConnection"Tb4b4b4, Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4(Tb4b4b4{
Tff7b72defaultTff7b72: Tb4b4b4{ Te6edf3onTff7b72: Te6edf3viTb4b4b4.Te6edf3fnTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3offTff7b72: Te6edf3viTb4b4b4.Te6edf3fnTb4b4b4(Tb4b4b4) Tb4b4b4}Tb4b4b4,
Tb4b4b4}Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3viTb4b4b4.Te6edf3mockTb4b4b4(Ta5d6ff"../../meshchatx/src/frontend/js/Utils"Tb4b4b4, Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4(Tb4b4b4{
Tff7b72defaultTff7b72: Tb4b4b4{ Te6edf3formatTimeAgoTff7b72: Tb4b4b4(Te6edf3dTb4b4b4) Tb4b4b4=> Ta5d6ff"1h ago" Tb4b4b4}Tb4b4b4,
Tb4b4b4}Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tff7b72const Te6edf3MaterialDesignIcon Tff7b72= Tb4b4b4{ Te6edf3templateTff7b72: Ta5d6ff'<div class="mdi"></div>'Tb4b4b4, Te6edf3propsTff7b72: Tb4b4b4[Ta5d6ff"iconName"Tb4b4b4] Tb4b4b4}Tb4b4b4;
Tff7b72function Te6edf3mountBellTb4b4b4(Te6edf3options Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4) Tb4b4b4{
Tff7b72return Te6edf3mountTb4b4b4(Te6edf3NotificationBellTb4b4b4, Tb4b4b4{
Tffa657globalTff7b72: Tb4b4b4{
Te6edf3componentsTff7b72: Tb4b4b4{ Te6edf3MaterialDesignIcon Tb4b4b4}Tb4b4b4,
Te6edf3directivesTff7b72: Tb4b4b4{ Ta5d6ff"click-outside"Tff7b72: Tb4b4b4{ Te6edf3mountedTff7b72: Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{Tb4b4b4}Tb4b4b4, Te6edf3unmountedTff7b72: Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{Tb4b4b4} Tb4b4b4} Tb4b4b4}Tb4b4b4,
Tb4b4b4}Tb4b4b4,
Tb4b4b4...Te6edf3optionsTb4b4b4,
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3describeTb4b4b4(Ta5d6ff"NotificationBell UI"Tb4b4b4, Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Te6edf3beforeEachTb4b4b4(Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Te6edf3viTb4b4b4.Te6edf3clearAllMocksTb4b4b4(Tb4b4b4)Tb4b4b4;
Tffa657globalTb4b4b4.Te6edf3axiosTb4b4b4.Te6edf3get Tff7b72= Te6edf3viTb4b4b4.Te6edf3fnTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3mockResolvedValueTb4b4b4(Tb4b4b4{ Te6edf3dataTff7b72: Tb4b4b4{ Te6edf3notificationsTff7b72: Tb4b4b4[Tb4b4b4]Tb4b4b4, Te6edf3unread_countTff7b72: T79c0ff0 Tb4b4b4} Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"renders bell button"Tb4b4b4, Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72const Te6edf3btn Tff7b72= Te6edf3wrapperTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff"button.relative.rounded-full"Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Te6edf3btnTb4b4b4.Te6edf3existsTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4.Te6edf3toBeTb4b4b4(Tff7b72trueTb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"shows unread badge when unreadCount > 0"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3unreadCount Tff7b72= T79c0ff5Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Te6edf3wrapperTb4b4b4.Te6edf3textTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4.Te6edf3toContainTb4b4b4(Ta5d6ff"5"Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"shows 9+ when unreadCount > 9"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3unreadCount Tff7b72= T79c0ff12Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Te6edf3wrapperTb4b4b4.Te6edf3textTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4.Te6edf3toContainTb4b4b4(Ta5d6ff"9+"Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"opens dropdown on button click"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4{ Te6edf3attachToTff7b72: Tffa657documentTb4b4b4.Te6edf3body Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff"button"Tb4b4b4)Tb4b4b4.Te6edf3triggerTb4b4b4(Ta5d6ff"click"Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3isDropdownOpenTb4b4b4)Tb4b4b4.Te6edf3toBeTb4b4b4(Tff7b72trueTb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Tffa657documentTb4b4b4.Te6edf3bodyTb4b4b4.Te6edf3textContentTb4b4b4)Tb4b4b4.Te6edf3toContainTb4b4b4(Ta5d6ff"Notifications"Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3unmountTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"shows Clear button when dropdown open and notifications exist"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tffa657globalTb4b4b4.Te6edf3axiosTb4b4b4.Te6edf3get Tff7b72= Te6edf3viTb4b4b4.Te6edf3fnTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3mockResolvedValueTb4b4b4(Tb4b4b4{
Te6edf3dataTff7b72: Tb4b4b4{
Te6edf3notificationsTff7b72: Tb4b4b4[
Tb4b4b4{ Te6edf3destination_hashTff7b72: Ta5d6ff"h1"Tb4b4b4, Te6edf3display_nameTff7b72: Ta5d6ff"A"Tb4b4b4, Te6edf3updated_atTff7b72: Tff7b72new Tffa657DateTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toISOStringTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3contentTff7b72: Ta5d6ff"Hi" Tb4b4b4}Tb4b4b4,
Tb4b4b4]Tb4b4b4,
Te6edf3unread_countTff7b72: T79c0ff1Tb4b4b4,
Tb4b4b4}Tb4b4b4,
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4{ Te6edf3attachToTff7b72: Tffa657documentTb4b4b4.Te6edf3body Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff"button"Tb4b4b4)Tb4b4b4.Te6edf3triggerTb4b4b4(Ta5d6ff"click"Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72await Tff7b72new Tffa657PromiseTb4b4b4(Tb4b4b4(Te6edf3rTb4b4b4) Tb4b4b4=> Te6edf3setTimeoutTb4b4b4(Te6edf3rTb4b4b4, T79c0ff50Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Tffa657documentTb4b4b4.Te6edf3bodyTb4b4b4.Te6edf3textContentTb4b4b4)Tb4b4b4.Te6edf3toContainTb4b4b4(Ta5d6ff"Clear"Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3unmountTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"shows No new notifications when empty"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4{ Te6edf3attachToTff7b72: Tffa657documentTb4b4b4.Te6edf3body Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff"button"Tb4b4b4)Tb4b4b4.Te6edf3triggerTb4b4b4(Ta5d6ff"click"Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Tffa657documentTb4b4b4.Te6edf3bodyTb4b4b4.Te6edf3textContentTb4b4b4)Tb4b4b4.Te6edf3toContainTb4b4b4(Ta5d6ff"No new notifications"Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3unmountTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Te6edf3itTb4b4b4(Ta5d6ff"dropdown has Notifications heading when open"Tb4b4b4, Tff7b72async Tb4b4b4(Tb4b4b4) Tb4b4b4=> Tb4b4b4{
Tff7b72const Te6edf3wrapper Tff7b72= Te6edf3mountBellTb4b4b4(Tb4b4b4{ Te6edf3attachToTff7b72: Tffa657documentTb4b4b4.Te6edf3body Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3findTb4b4b4(Ta5d6ff"button"Tb4b4b4)Tb4b4b4.Te6edf3triggerTb4b4b4(Ta5d6ff"click"Tb4b4b4)Tb4b4b4;
Tff7b72await Te6edf3wrapperTb4b4b4.Te6edf3vmTb4b4b4.Te6edf3$nextTickTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72const Te6edf3h3 Tff7b72= Tffa657documentTb4b4b4.Te6edf3bodyTb4b4b4.Te6edf3querySelectorTb4b4b4(Ta5d6ff"h3"Tb4b4b4)Tb4b4b4;
Te6edf3expectTb4b4b4(Te6edf3h3Tff7b72?Tb4b4b4.Te6edf3textContentTb4b4b4)Tb4b4b4.Te6edf3toBeTb4b4b4(Ta5d6ff"Notifications"Tb4b4b4)Tb4b4b4;
Te6edf3wrapperTb4b4b4.Te6edf3unmountTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
Tb4b4b4}Tb4b4b4)Tb4b4b4;
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────